package com.abaaba.project2.service.serviceImpl;

import com.abaaba.project2.bean.System;
import com.abaaba.project2.bean.bo.MallConfigExpressBO;
import com.abaaba.project2.bean.vo.AdminConfigExpressVo;
import com.abaaba.project2.mapper.SystemMapper;
import com.abaaba.project2.service.AdminConfigExpressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author Hedgehog
 * @Date 2021/6/6 22:06
 * @Version 1.0
 */
@Service
public class AdminConfigExpressServiceImpl implements AdminConfigExpressService {


    @Autowired
    SystemMapper systemMapper;

    @Override
    public AdminConfigExpressVo selectConfigExpress() {

        System systemValue = systemMapper.selectByPrimaryKey(39);
        System systemMin = systemMapper.selectByPrimaryKey(37);
         //获取值
        String value = systemValue.getKeyValue();
        String min = systemMin.getKeyValue();

        //封装
        AdminConfigExpressVo adminConfigExpressVo = new AdminConfigExpressVo();
        adminConfigExpressVo.setCskaoyanmall_express_freight_value(value);
        adminConfigExpressVo.setCskaoyanmall_express_freight_min(min);

        return adminConfigExpressVo;
    }

    @Override
    public void updateExpress(MallConfigExpressBO mallConfigExpressBO) {
        System systemValue = new System();
        systemValue.setId(39);
        systemValue.setKeyValue(mallConfigExpressBO.getCskaoyanmall_express_freight_value());

        System systemMin = new System();
        systemMin.setId(37);
        systemMin.setKeyValue(mallConfigExpressBO.getCskaoyanmall_express_freight_min());


        systemMapper.updateByPrimaryKeySelective(systemValue);
        systemMapper.updateByPrimaryKeySelective(systemMin);

    }
}
